package engine;

import android.util.Log;

import com.tetris.project.Shr_Res;

public class PrintingThread extends Thread {
	private Board mBoard;

	public PrintingThread(Board board)
	{
		mBoard = board;
	}

	public void run()
	{
		while (Shr_Res.printing) {
			synchronized (mBoard) {
/*
				try {
					if (Shr_Res.sleep)
						mBoard.wait();
					Shr_Res.sleep = false;
					Log.d(Shr_Res.TAG, "" + "I came here after wake up");
				} catch (InterruptedException e) {}
*/
				/*
				 * ----------------    -----
				 * | 1 | 1 | 1 |...... | 1 |
				 * | 1 | 1 | 1 |...... | 1 |
				 * | 1 | 1 | 1 |...... | 1 |
				 * 
				 * 
				 * 
				 * | 1 | 1 | 1 |...... | 1 |
				 * ----------------     ---
				 * 
				 */

			if (Shr_Res.print) {
				String myLog = new String();

				for (int i = 0; i <= (int) (Board.BOARD_ROWS * 1.5); i++) {
					myLog += "-";
				}
				Log.d(Shr_Res.TAG, "" + myLog);

				for (int i = 0; i < Board.BOARD_ROWS; i++) {
					myLog = "";
					for (int j = 0; j < Board.BOARD_COLS; j++) {
						myLog +="| " + "0x" + Integer.toHexString(
							mBoard.getBoard()[i][j] & 0xFFFFFFFF);
					}
					myLog += " |";
					Log.d(Shr_Res.TAG, "" + myLog);
				}

				myLog = "";
				for (int i = 0; i <= (int) (Board.BOARD_ROWS * 1.5); i++) {
					myLog += "-";
				}

				Log.d(Shr_Res.TAG, "" + myLog);
				//if (Shr_Res.printing)
				//	Shr_Res.sleep = true;
				Shr_Res.print = false;
			}
		}
	}}
}
